package com.jerry.huihome.module.find.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.TextView;

import com.jerry.huihome.R;
import com.jerry.huihome.base.BaseApplication;
import com.jerry.huihome.base.BaseViewHolder;
import com.jerry.huihome.base.MyBaseAdapter;
import com.jerry.huihome.module.find.entity.AssessForeman;
import com.jerry.huihome.views.RoundImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/5/13.
 */
public class AssessFroemanAdapter extends MyBaseAdapter<AssessForeman.BodyBean.AssessItemsBean> {
    private Context context;
    private DisplayImageOptions options;
    public AssessFroemanAdapter(Context context, List<AssessForeman.BodyBean.AssessItemsBean> list) {
        super(context, list);
        this.context = context;
        options = new DisplayImageOptions.Builder().cacheInMemory(true)
                .cacheOnDisk(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .build();
    }

    @Override
    public int getLayoutId() {
        return R.layout.comment_item;
    }

    @Override
    public BaseViewHolder getViewHolder() {
        return new ViewHolder();
    }

    @Override
    public void bindViews(View view, BaseViewHolder viewHolder) {
        AssessForeman.BodyBean.AssessItemsBean item = getItem(viewHolder.position);
        ViewHolder mViewHolder = (ViewHolder) viewHolder;
        mViewHolder.tvCommentName.setText(item.getUsername());
        mViewHolder.tvCommentDetailTime.setText(item.getAssessDate());
        mViewHolder.tvCommentDetailContent.setText((String) item.getAssessTxt());
        mViewHolder.tvStyle.setText(item.getPhase());
        mViewHolder.tvProfession.setText("专业"+item.getScoreProf());
        mViewHolder.tvService.setText("服务"+item.getScoreManner());
        mViewHolder.tvActive.setText("活跃"+item.getScoreActive());
        String avatar = item.getAvatar();
        if (avatar != null & avatar.length()>0){
            BaseApplication.getApplication().getImageLoader().displayImage(avatar,mViewHolder.rivImageHead,options);
        }else {
            mViewHolder.rivImageHead.setImageResource(R.drawable.avator_default);
        }
    }

    static class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_comment_name)
        TextView tvCommentName;
        @BindView(R.id.tv_comment_detail_time)
        TextView tvCommentDetailTime;
        @BindView(R.id.tv_comment_detail_content)
        TextView tvCommentDetailContent;
        @BindView(R.id.tv_style)
        TextView tvStyle;
        @BindView(R.id.tv_profession)
        TextView tvProfession;
        @BindView(R.id.tv_service)
        TextView tvService;
        @BindView(R.id.tv_active)
        TextView tvActive;
        @BindView(R.id.riv_head_img)
        RoundImageView rivImageHead;
    }
}
